package com.kingsoft.miot.bridge.iam.common;

import org.apache.commons.lang3.StringUtils;

/**
 * 共同参数
 * 
 * 说明: 公共请求参数是每个身份与访问管理接口都需要使用到的请求参数。
 * 
 * @author HUJIANQING
 *
 */
public class CommonParam {

	private String Action;
	private String Version;
	private String X_Amz_Algorithm;
	private String X_Amz_Credential;
	private String X_Amz_Date;
	private String X_Amz_SignedHeaders;
	private String X_Amz_Signature;

	/**
	 * 构建公共参数
	 * 
	 * @return
	 */
	protected String buildForReq() {
		StringBuilder builder = new StringBuilder();
		// 关键参数不能为空
		if (StringUtils.isAnyBlank(new String[] { Action, Version })) {
			throw new IllegalArgumentException("公共参数不能为空。");
		}
		builder.append("Action" + getAction() + "&");
		builder.append("Version" + getVersion() + "&");
		if (StringUtils.isNotBlank(getX_Amz_Algorithm())) {
			builder.append("Action" + getX_Amz_Algorithm() + "&");
		}
		if (StringUtils.isNotBlank(getX_Amz_Credential())) {
			builder.append("Action" + getX_Amz_Credential() + "&");
		}
		if (StringUtils.isNotBlank(getX_Amz_Date())) {
			builder.append("Action" + getX_Amz_Date() + "&");
		}
		if (StringUtils.isNotBlank(getX_Amz_SignedHeaders())) {
			builder.append("Action" + getX_Amz_SignedHeaders() + "&");
		}
		if (StringUtils.isNotBlank(getX_Amz_Signature())) {
			builder.append("Action" + getX_Amz_Signature());
		}
		return builder.toString();
	}
//	

	public String getAction() {
		return Action;
	}

	public void setAction(String action) {
		Action = action;
	}

	public String getVersion() {
		return Version;
	}

	public void setVersion(String version) {
		Version = version;
	}

	public String getX_Amz_Algorithm() {
		return X_Amz_Algorithm;
	}

	public void setX_Amz_Algorithm(String x_Amz_Algorithm) {
		X_Amz_Algorithm = x_Amz_Algorithm;
	}

	public String getX_Amz_Credential() {
		return X_Amz_Credential;
	}

	public void setX_Amz_Credential(String x_Amz_Credential) {
		X_Amz_Credential = x_Amz_Credential;
	}

	public String getX_Amz_Date() {
		return X_Amz_Date;
	}

	public void setX_Amz_Date(String x_Amz_Date) {
		X_Amz_Date = x_Amz_Date;
	}

	public String getX_Amz_SignedHeaders() {
		return X_Amz_SignedHeaders;
	}

	public void setX_Amz_SignedHeaders(String x_Amz_SignedHeaders) {
		X_Amz_SignedHeaders = x_Amz_SignedHeaders;
	}

	public String getX_Amz_Signature() {
		return X_Amz_Signature;
	}

	public void setX_Amz_Signature(String x_Amz_Signature) {
		X_Amz_Signature = x_Amz_Signature;
	}

}
